package com.jsgt.greekfire.ui.coin.ordermanagement

import android.os.Bundle
import androidx.recyclerview.widget.LinearLayoutManager
import com.fhx.core.base.BaseFragment
import com.fhx.core.utils.ToastUtils
import com.jsgt.greekfire.R
import com.jsgt.greekfire.ui.coin.CoinBean
import com.jsgt.greekfire.ui.coin.CoinListFragment
import com.jsgt.greekfire.ui.coin.adapter.CoinAdapter
import com.jsgt.greekfire.ui.coin.adapter.HistoricalOrderAdapter
import kotlinx.android.synthetic.main.fragment_coin_list.*
import kotlinx.android.synthetic.main.fragment_historical_orders.*

private const val ARG_PARAM1 = "param1"

class HistoricalOrdersFragment : BaseFragment() {
    private var param1: String? = null
    var carList = mutableListOf<HistoricalOrdersBean>()
    private val historicalOrderAdapter by lazy {

        var bean1 = HistoricalOrdersBean("1","GFT","2020/04/16","0.00005789","7564.87","64")
        var bean2 = HistoricalOrdersBean("2","ETH","2020/08/12","56513","6461.1","64")
        var bean3 = HistoricalOrdersBean("1","BTC","2020/12/13","84653.654","84561","64")

        carList.add(bean1)
        carList.add(bean2)
        carList.add(bean3)

        HistoricalOrderAdapter(context!!,R.layout.item_historical_order_list)
    }
    companion object {
        @JvmStatic
        fun newInstance(param1: String) =
            HistoricalOrdersFragment().apply {
                arguments = Bundle().apply {
                    putString(ARG_PARAM1, param1)
                }
            }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        arguments?.let {
            param1 = it.getString(ARG_PARAM1)
        }
    }

    override fun getLayoutId(): Int = R.layout.fragment_historical_orders

    override fun main() {
        rvHistoricalOrders.layoutManager = LinearLayoutManager(context)
        rvHistoricalOrders.adapter = historicalOrderAdapter
        historicalOrderAdapter?.setNewData(carList)
        historicalOrderAdapter.setOnItemClickListener { adapter, view, position ->
            ToastUtils.show(activity!!,historicalOrderAdapter.data.get(position).currency)
        }
    }

}